package cx.ath.skyflyer.gpslog.util;

import j2meunit.framework.*;

/**
 *
 * @author lego
 */
public class TokenizerTest extends TestCase {

    public TokenizerTest() {
    }

    private TokenizerTest(String name, TestMethod method) {
        super(name, method);
    }

    public void setUp() {
    }

    public void tearDown() {
    }

    public Test suite() {
        TestSuite ts = new TestSuite();

		ts.addTest(new TokenizerTest("testHasNext", new TestMethod() {
            public void run(TestCase tc) {
                ((TokenizerTest)tc).testHasNext();
            }
        }));

		ts.addTest(new TokenizerTest("testNext", new TestMethod() {
            public void run(TestCase tc) {
                ((TokenizerTest)tc).testNext();
            }
        }));

		ts.addTest(new TokenizerTest("testNextDelimiterIndex", new TestMethod() {
            public void run(TestCase tc) {
                ((TokenizerTest)tc).testNextDelimiterIndex();
            }
        }));


        return ts;
    }

    private void testHasNext() {
        Tokenizer t = new Tokenizer("");
        assertTrue(!t.hasNext());

        t = new Tokenizer("a");
        assertTrue(t.hasNext());
        assertEquals("a", t.next());
    }

    private void testNext() {
        Tokenizer t = new Tokenizer("a,,bcdef123,g*5923,d");
        String[] expected = new String[] { "a", "", "bcdef123", "g", "5923", "d" };

        for (int i = 0; i < 6; ++i) {
            assertTrue(t.hasNext());
            String s = t.next();

            assertEquals(expected[i], s);
        }

        assertTrue(!t.hasNext());

    }

    private void testNextDelimiterIndex() {

    }
}
